home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9176 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: hubcap.clemson.edu!hubcap!mjs
  2. From: mjs@hubcap.clemson.edu (M. J. Saltzman)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: f;oating point precision
  5. Date: 6 Mar 96 15:50:09 GMT
  6. Organization: Clemson University
  7. Message-ID: <mjs.826127409@hubcap>
  8. References: <4hit8c$8lm@news.microsoft.com> <4hk7o5$gmk@crc-news.doc.ca>
  9. NNTP-Posting-Host: hubcap.clemson.edu
  10. X-Newsreader: NN version 6.5.0 #1
  11.  
  12. don@mars.dgrc.doc.ca (Donald McLachlan) writes:
  13.  
  14. >An even simpler example of the problem.  The nice simple number .1 base10 cannot
  15. >be *exactly* represented as a binary number.  My simple way of converting from
  16. >base10 decimals to binary is:
  17.  
  18. >[algorithm for converting a decimal fraction to binary...]
  19.  
  20. >For .1 base10, the process is:
  21.  
  22. >    math            result
  23. >    .1 * 2 = 0.2        .0
  24. >    .2 * 2 = 0.4        .00    <----------------
  25. >    .4 * 2 = 0.8        .000            |
  26. >    .8 * 2 = 1.6        .0001            |
  27. >    .6 * 2 = 1.2        .00011            |
  28. >    .2 * 2 = 0.4  *** we have seen this case before, so we are in an infinite
  29. >loop (what is this called, and irrational number?) ***
  30.  
  31. No, it's a rational number (the ratio of two integers, in this case
  32. 1/10 decimal or 1/1010 binary).  Decimal or other radix expansion of a
  33. rational number always ends in an infinitely repeating finite-length
  34. sequence of digits (perhaps the infinitely repeating sequence of
  35. digits is '0', in which case we usually ignore it and say the
  36. expansion is finite).
  37.  
  38. Irrational numbers are the ones that have infinite expansions that
  39. never repeat, like pi, e (the base of the natural log), sqrt(2.0),
  40. etc.
  41. -- 
  42.         Matthew Saltzman
  43.         Clemson University Math Sciences
  44.         mjs@clemson.edu
  45.